package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {


    /**
     * @description: 根据用户名查询员工信息
     * @author: tanbobin
     * @date: 2024/5/27 10:51
     * @param:
     * @param username
     * @return:
     * @return com.sky.entity.Employee
     **/
    @Select("select id, name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user from employee where username = #{username}")
    public Employee findByUsername(String username);

    /**
     * @description: 新增员工
     * @author: tanbobin
     * @date: 2024/5/28 22:12
     * @param:
     * @param employee
     * @return:
     **/
    @AutoFill(OperationType.INSERT)
    @Insert("insert into employee (name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user)" +
            "    values (#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Employee employee);

    /**
     * @description: 动态查询数据
     * @author: tanbobin
     * @date: 2024/5/28 22:13
     * @param:
     * @param name
     * @return:
     * @return java.util.List<com.sky.entity.Employee>
     **/
    List<Employee> list(String name);

    /**
     * @description: 启用/禁用员工
     * @author: tanbobin
     * @date: 2024/5/29 11:23
     * @param:
     * @param employee
     * @return:
     **/
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);

    /**
     * @description: 根据id查询员工信息
     * @author: tanbobin
     * @date: 2024/5/29 16:02
     * @param:
     * @param id
     * @return:
     * @return com.sky.entity.Employee
     **/
    @Select("select id, name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user from employee where id = #{id}")
    Employee queryById(Long id);
}
